/*******************************************************************************
 ** Name: dmg.cpp                                                       **
 ** Description:              **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $GOVTSANCT_WIKI/License-software.                **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $HOME/LICENSE.                      **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 **                                                                           **
 ** Ref: $HeadURL$
 ******************************************************************************/
// Portions (c) 2012 Open Design Strategies, LLC.
// $Id$
// Last Modified by $Author$

#include <math.h>
#include <ctime>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

#include "dmg.hpp"


int
Damage::Average(int min, int max, bool roundDown)
{
	if (roundDown)
		return( floor((min+max)/2) );
	else
		return( ceil((min+max)/2) );
}

int
Damage::Generate(int min, int max, bool roundDown)
{
	boost::mt19937	gen(std::time(0));
	boost::random::uniform_int_distribution<> dist(min,max);
	return dist(gen);
}

//int
//Damage::DPS(time_t start, time_t end, int dmg)
//{
//	boost::posix_time::ptime ptime1 = boost::posix_time::from_time_t(start);
//	boost::posix_time::ptime ptime2 = boost::posix_time::from_time_t(end);
//	boost::posix_time::time_period interval(ptime1,ptime2);
//
//
//	return( dmg/interval.length());
//}
